import re
str = 'TCP server 172.16.1.101:443 localserver 172.16.66.1:53710, idle 0:01:09, bytes 27575949, flags UIO'
result = re.match('(^[A-Za-z]+)\s+server\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5})\s+localserver\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5}),\s+idle\s+(\d+):(\d+):(\d+),\s+bytes\s+(\d+),\s+flags\s+(\w+)',str.strip()).groups()

print('%(protocol)-18s : %(protocol-01)s'%{'protocol': 'protocol','protocol-01': result[0]})
print('%(server)-18s : %(server-ip)s'%{'server': 'server','server-ip': result[1]})
print('%(localserver)-18s : %(localserver-ip)s'%{'localserver': 'localserver','localserver-ip': result[2]})
print('%(idle)-18s : %(hour)s小时 %(minute)s分钟 %(seconds)s秒'%{'idle': 'idle','hour': result[3],'minute': result[4],'seconds': result[5]})
print('%(bytes)-18s : %(bytes-num)s'%{'bytes': 'bytes','bytes-num': result[6]})
print('%(flags)-18s : %(flags-01)s'%{'flags': 'flags','flags-01': result[7]})



# print(result[0])
# print(result[1])
# print(result[2])
# print(result[3])
# print(result[4])
# print(result[5])
# print(result[6])
# print(result[7])